﻿using App.Model;
using App.Untiys;
using DtRlDeviceApiNet.Models;
using SqlSugar;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Win.Dal;

namespace App.Desk.Pro.SamplingData
{
    public partial class FrmEditSupplierCode : UIEditForm
    {
        public int _samplingId = 0;
        public string _supplierCode = "";
        public FrmEditSupplierCode(int samplingId,string supplierCode)
        {
            _samplingId = samplingId;
            _supplierCode = supplierCode;
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if(string.IsNullOrEmpty(txtSupplierCode.Text))
                {
                    UIMessageBox.ShowError("供应商简码不能为空！");
                    return;
                }
                if (ProSamplingServices.EditSupplierCode(_samplingId, txtSupplierCode.Text))
                {
                    UIMessageBox.ShowSuccess("修改成功");
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                UIMessageBox.ShowSuccess("修改成功" + ex.Message);
                LogHelper.DoWriteLogType(LogType.Plan, $"修改成功{ex.Message}");
            }
        }

        private void FrmEditSupplierCode_Load(object sender, EventArgs e)
        {
            txtSupplierCode.Text = _supplierCode;
        }
    }
}
